﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using NopSolutions.NopCommerce.Common.Categories;
using NopSolutions.NopCommerce.Common.SEO;
using NopSolutions.NopCommerce.Common.SEO.Sitemaps;
using NopSolutions.NopCommerce.Common.Utils;
using NopSolutions.NopCommerce.Common.Xml;

namespace NopSolutions.NopCommerce.Web
{
    public partial class SitemapSEOPage : BaseNopPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Response.ContentType = "text/xml";
            Response.ContentEncoding = new UTF8Encoding();

            SitemapGenerator sitemapGenerator = new SitemapGenerator();
            string siteMap = sitemapGenerator.Generate();
            Response.Write(siteMap);
            Response.End();
        }

        //protected void Page_Load(object sender, EventArgs e)
        //{
        //    Response.ContentType = "text/xml";
        //    Response.ContentEncoding = new UTF8Encoding();
        //    Response.Write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");

        //    Response.Write("<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">");
        //    WriteGoogleSitemapForCategories(0);
        //    Response.Write("</urlset>");
        //    Response.End();
        //}

        //protected void WriteGoogleSitemapForCategories(int ParentCategoryID)
        //{
        //    CategoryCollection categories = CategoryManager.GetAllCategories(ParentCategoryID);
        //    foreach (Category category in categories)
        //    {
        //        Response.Write("<url>");
        //        Response.Write("<loc>" + XmlHelper.XmlEncode(SEOHelper.GetCategoryURL(category.CategoryID)) + "</loc> ");
        //        Response.Write("<changefreq>" + "monthly" + "</changefreq> ");
        //        Response.Write("<priority>" + "0.8" + "</priority> ");
        //        Response.Write("</url>");
        //        WriteGoogleSitemapForCategories(category.CategoryID);
        //    }
        //}
    }
}
